import request from '@/utils/request'

// 查询定时任务列表
export function listJob(query) {
  return request({
    url: '/bot/job/list',
    method: 'get',
    params: query
  })
}

// 查询定时任务详细
export function getJob(id) {
  return request({
    url: '/bot/job/' + id,
    method: 'get',
    headers: {
      custom:{
        showLoading:true
      }
    }
  })
}

// 新增定时任务
export function addJob(data) {
  return request({
    url: '/bot/job',
    method: 'post',
    data: data,
    headers: {
      custom:{
        showLoading:true,
        loadingMsg:'处理中...'
      }
    }
  })
}

// 修改定时任务
export function updateJob(data) {
  let mData = JSON.stringify(data);
  let params = JSON.parse(mData);
  params.config = JSON.stringify(params.config)
  return request({
    url: '/bot/job',
    method: 'put',
    data: params,
    headers: {
      custom:{
        showLoading:true,
        loadingMsg:'处理中...'
      }
    }
  })
}

// 删除定时任务
export function delJob(id) {
  return request({
    url: '/bot/job/' + id,
    method: 'delete',
    headers: {
      custom:{
        showLoading:true,
        loadingMsg:'处理中...'
      }
    }
  })
}
